<!DESCRIPTION>Using an external JavaScript file, simply define the rules for how each field should be validated and you're set. Piece of cake! And since it is it's own .js file, it's easy to use the code on every page of your site. Currently only validates text, numbers and e-mail addresses. <!/DESCRIPTION>
<!CATEGORY>Forms<!/CATEGORY>
<!SCRIPT>
<!-- START OF SCRIPT -->
<!-- FIVE STEPS TO INSTALL EXTERNAL JS:
1. Copy the first code in a new file, save it as validation.js
2. Include the .js file in the HEAD of your HTML document
3. Define the validation rules for each field in the HEAD section
4. Insert the onLoad event handler into your BODY tag
5. Add validate() to your submit button, as shown below -->
<!-- STEP ONE: Paste this code into a new file, save as validation.js -->
// Generic Form Validation
// Jacob Hage (jacob@hage.dk)
var checkObjects = new Array();
var errors = "";
var returnVal = false;
var language = new Array();
language["header"] = "The following error(s) occured:"
language["start"] = "->";
language["field"] = " Field ";
language["require"] = " is required";
language["min"] = " and must consist of at least ";
language["max"] = " and must not contain more than ";
language["minmax"] = " and no more than ";
language["chars"] = " characters";
language["num"] = " and must contain a number";
language["email"] = " must contain a valid e-mail address";